﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace SSP
{
    class SSPCamera : SSPNode
    {
        int startPosition;
        int endPosition;
        SSPScrollingBackground scrollingBackground;

        public SSPCamera()
        {
        }

        public SSPCamera(int start, int end)
        {
            startPosition = start;
            endPosition = end;
        } 

        public SSPCamera(int start, int end, SSPScrollingBackground sb)
        {
            startPosition = start + (int)(SSPDirector.Instance.windowSize().X /2);
            endPosition = end; 
            scrollingBackground = sb;
            position = new Vector2(startPosition,(SSPDirector.Instance.windowSize().Y /2));
            scrollingBackground.cameraPosition = position;
        }

        public Vector2 ConvertToStageSpace(Vector2 element_position)
        {
            return (element_position - position) + SSPDirector.Instance.windowSize()*(Single)0.5; 
        }

        public override void update()
        {
            scrollingBackground.cameraPosition = position;
        }
    }
}
